/*
Date:20210602 22:48PM
key:记忆化dfs，unordered_set<int>s不知道为什么有问题，只能用set
*/
class Solution {
public:
    void dfs(vector<int>& nums,vector<int>& v,set<vector<int>>&S,int i1)
    {
        //v要有两个以上的元素才能被保留
        if(v.size()>1)
        {
            S.insert(v);
        }
        for(int i=i1;i<nums.size();i++)
        {
            //v空或者当前大于v最后一个元素
            if(v.empty()||(v[v.size()-1]<=nums[i]))
            {
                v.push_back(nums[i]);
                dfs(nums,v,S,i+1);
                v.pop_back();
            }
        }
    }
    vector<vector<int>> findSubsequences(vector<int>& nums) 
    {
        vector<int> v;
        vector<vector<int>>V;
        //unordered_set<int>s;
        set<vector<int>>S;
        dfs(nums,v,S,0);
        const int n=S.size();
        V.resize(n);
        int i=0;
        for(auto&g:S)
        {
            V[i]=g;
            i++;
        }
        return V;
    }
};